package com.collection;

import java.security.SecureRandom;

public class SecureRandomStringGenerator {
    private static final String alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

    private static String generateSecureRandomString(int length, String alphabet) {
        SecureRandom secureRandom = new SecureRandom();
        StringBuilder sb = new StringBuilder(length);
        for (int i = 0; i < length; i++) {
            int index = secureRandom.nextInt(alphabet.length());
            char ch = alphabet.charAt(index);
            sb.append(ch);
        }
        return sb.toString();
    }

    public static String generateRandomString(int length){
       return generateSecureRandomString(length, alphabet);
    }
}